package com.qys.livesMall.shop.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qys.livesMall.common.constants.Constants;
import com.qys.livesMall.shop.dao.H2ShopBalanceDao;
import com.qys.livesMall.shop.mapper.H2ShopBalanceMapper;
import com.qys.livesMall.shop.modal.entity.H2ShopBalance;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 店铺余额表 服务实现类
 * </p>
 *
 * @author
 * @since 2023-06-06
 */
@Service
public class H2ShopBalanceDaoImpl extends ServiceImpl<H2ShopBalanceMapper, H2ShopBalance> implements H2ShopBalanceDao {

    @Override
    public H2ShopBalance getByUserId(Long userId) {
        LambdaQueryWrapper<H2ShopBalance> qw=new LambdaQueryWrapper<>();
        qw.eq(H2ShopBalance::getUserId,userId);
        qw.eq(H2ShopBalance::getDeleted, Constants.YesNo.NO);
        qw.last("limit 1");
        return getOne(qw);
    }

    @Override
    public List<H2ShopBalance> getByUserIds(List<Long> userIds) {
        LambdaQueryWrapper<H2ShopBalance> qw=new LambdaQueryWrapper<>();
        qw.in(H2ShopBalance::getUserId,userIds);
        qw.eq(H2ShopBalance::getDeleted, Constants.YesNo.NO);
        return list(qw);
    }

    @Override
    public H2ShopBalance getByShopId(Long shopId) {
        LambdaQueryWrapper<H2ShopBalance> qw=new LambdaQueryWrapper<>();
        qw.eq(H2ShopBalance::getShopId,shopId);
        qw.eq(H2ShopBalance::getDeleted, Constants.YesNo.NO);
        qw.last("limit 1");
        return getOne(qw);
    }

    @Override
    public List<H2ShopBalance> liatByShopIds(List<Long> shopIds) {
        LambdaQueryWrapper<H2ShopBalance> qw=new LambdaQueryWrapper<>();
        qw.in(H2ShopBalance::getShopId,shopIds);
        qw.eq(H2ShopBalance::getDeleted, Constants.YesNo.NO);
        return list(qw);
    }


}
